gh-145685: Avoid contention on TYPE_LOCK in super() lookups#145775
gh-145685: Avoid contention on TYPE_LOCK in super() lookups#145775colesbury merged 3 commits intopython:mainfrom
Conversation
mpage
left a comment
There was a problem hiding this comment.
LGTM. Should we add a test to the scaling benchmark that reproduces the issue?
Objects/typeobject.c
Outdated
| _PyThreadState_PushCStackRef(tstate, &mro_ref); | ||
| mro_ref.ref = PyStackRef_FromPyObjectNew(mro); |
There was a problem hiding this comment.
Doesn't need to be in this PR, but would it be worth adding another function that combines these two operations?
There was a problem hiding this comment.
Yeah, makes sense.
|
This is enough to fix class Base:
def method(self):
return 1
class Derived(Base):
def method(self):
return super().method()
@register_benchmark
def super_call():
obj = Derived()
for _ in range(1000 * WORK_SCALE):
obj.method() |
|
Actually, maybe it's worth adding the different class benchmark now and I'll update it later. |
|
Thanks @colesbury for the PR 🌮🎉.. I'm working now to backport this PR to: 3.14. |
|
Sorry, @colesbury, I could not cleanly backport this to |
…ups (pythongh-145775) (cherry picked from commit bdf6de8) Co-authored-by: Sam Gross <colesbury@gmail.com>
|
GH-145804 is a backport of this pull request to the 3.14 branch. |
_PyType_Lookup/_PyType_LookupStackRefAndVersion#145685